/*
 * MidiControl.cpp
 *
 *  Created on: 18/lug/2011
 *      Author: marcolembo
 */

#include "MidiControl.h"
#include "MidiNoteStrategy.h"
#include "MidiCcStrategy.h"

namespace ml
{

    MidiControl::MidiControl()
    : m_midiChannel(1)
    {
        m_driver = 0;
        m_strategy = new MidiCcStrategy(); //di default
    }

    MidiControl::MidiControl(Driver * _driver)
    {
        m_driver = _driver;
        m_strategy = new MidiCcStrategy();
    }


    void MidiControl::SetStrategy(enStrategyType type)
    {
        if(m_strategy)
            delete m_strategy;

        if(type == eNote)
            m_strategy = new MidiNoteStrategy();
        else if(type == eCC)
        {
            m_strategy = new MidiCcStrategy();
        }
    }

    void MidiControl::SetMidiChannel(short ch)
    {
        m_midiChannel = ch;
    }
    short MidiControl::GetMidiChannel() const
    {
        return m_midiChannel;
    }

    MidiControl::~MidiControl()
    {
        delete m_driver;
        delete m_strategy;
    }

    void MidiControl::SendMidiEvent()
    {
       // short newValue = m_driver->ReadValue();
//        m_strategy->Execute(newValue);

    }

}
